<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
</head>
<body class="no-skin">
<div class="main-container" id="main-container">


    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="pull-left">

                            <button class="btn btn-sm btn-info" id="query">条件搜索</button>
                            <%-- <shiro:hasPermission name="modules:sys:huashu:query"></shiro:hasPermission> --%>
                            <%--<button class="btn btn-sm btn-success" id="create">手动新建任务</button>--%>
                            <%--<button class="btn btn-sm btn-default" id="edits">任务详情</button>--%>
                            <%--<button class="btn btn-sm btn-info" id="createLog">任务催办</button>--%>
                            <%-- 									<shiro:hasPermission name="modules:sys:huashu:edit"></shiro:hasPermission>
                             --%>

                            <%-- 									<shiro:hasPermission name="modules:sys:huashu:create"></shiro:hasPermission>
                             --%>
                            <!-- <button class="btn btn-sm btn-success" id="createCla">新增分类</button> -->
                            <button class="btn btn-sm btn-danger" id="delete" style="display: none;">删除</button>
                            <%--<shiro:hasPermission name="modules:sys:dept:excel">
                                <button class="btn btn-sm btn-pink" id="export">导出</button>
                            </shiro:hasPermission>--%>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>


</div><!-- /.main-container -->
</div>
<!-- footer -->

<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<!-- dialog -->
<%@ include file="/WEB-INF/views/include/dialog.jsp" %>


<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/gradepoint"></s:url>/"
    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = ['', '考核类别', '考核任务名', '考核者', '分数', '考核任务单号', '考核内容', '来源'];
    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'checkType', index: 'checkType', width: 160, editable: true},
        {name: 'taskName', index: 'taskName', width: 160, editable: true},
        {name: 'checkObject', index: 'checkObject', width: 160, editable: true},
        {name: 'soucre', index: 'soucre', width: 160, editable: true},
        {name: 'taskId', index: 'taskId', width: 160, editable: true},
        {name: 'taskContent', index: 'taskContent', width: 160, editable: true},
        {name: 'sources', index: 'sources', width: 160, editable: true}
        // {name: 'startDate', index: 'startDate', width: 160, editable: true},
        // {name: 'endDate', index: 'endDate', width: 160, editable: true},
        // {name: 'expirationDate', index: 'expirationDate', width: 160, editable: true},
        // {name: 'supervisionResult', index: 'supervisionResult', width: 160, editable: true},
        // {name: 'taskLog', index: 'taskLog', width: 160, editable: true}
    ];

    //jqgrid的具体执行方法
    jqgrid({
        shrinkToFit: false,
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager"
    });

    //加载查询对话框
    $("#queryDialog").load(getUrl("filter"));

    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    var exportData = '';
    //显示查询对话框
    var queryDialog = $("#queryDialog");
    $("#query").click(function () {
        showDialog({
            dialogTitle: '条件搜索',
            dialogBody: queryDialog,
            dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
                "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
        });
    });

    //具体查询方法
    function query() {

        exportData = $('#formDialog form').serialize();
        seachJqgird("#gridTable", "#formDialog form");
        $("#formDialog").modal('hide');
    }

    //更新操作
    $("#edits").click(function () {
        showEditView();
    });
    //催办操作
    $("#createLog").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("createTaskLog"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    //执行更新操作
    function edit() {
        // if ($("#myform").data("changed")) {
        //     console.log("输入框修改过！")
        // } else {
        //     alert("没有修改过，无法提交！");
        //     return;
        // }
        console.log("更新操作")
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    //显示编辑对话框
    function showEditView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    /*function showLogEditView() {
        console.log("ciban s sddskddj ")
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("createTaskLog"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',

        });
    }*/

    //显示编辑对话框
    function showView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "考核详情",
            dialogUrl: getUrl("showDetail"),
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }


    $("#exportSummary").click(function () {
        // exportData=decodeURIComponent(exportData,true);//解码
        var url = "/export/ExportSummary" + '?' + exportData;
        console.log(exportData);
        window.open(url);

    });

    //删除
    $("#delete").click(function () {
        showDeleteView();
    });

    //显示删除对话框
    function showDeleteView() {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定删除?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "删除成功",
            successTitle: "消息对话框",
            failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    }

    //显示创建对话框
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '创建对话框',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">提交审核</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //分类编辑框
    $("#createCla").click(function () {
        loadDialog({
            dialogTitle: '创建对话框',
            dialogUrl: getUrl("createCla"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //保存数据
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }


    $("#gridTable").dblclick(function (e) {
        showView();
    });


    //流程图表js
    $(function () {
        $(".nav>li:nth-child(7)").addClass("active");
    })
</script>

</body>
</html>